package com.zl.learning.arithmetic.leetcode;

import org.junit.Test;

import java.util.Arrays;

public class TestArray {

    @Test
    public void test1() {
        int[] v = {1, 2, 3, 4, 5};
        reverse(v, 5);
        System.out.println(Arrays.toString(v));
    }

    public void reverse(int[] v, int N) {
        int i = 0;
        int j = N - 1;
        while (i < j) {
            swap(v, i, j);
            i++;
            j--;
        }
    }

    public void swap(int a[], int i, int j) {
        int temp;
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }
}
